home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / guile-ii.src / guile-ii / guile-src / libguile / pairs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-16  |  5.4 KB  |  190 lines

  1. /* classes: h_files */
  2.  
  3. #ifndef PAIRSH
  4. #define PAIRSH
  5. /*    Copyright (C) 1995 Free Software Foundation, Inc.
  6.  * 
  7.  * This program is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; either version 2, or (at your option)
  10.  * any later version.
  11.  * 
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this software; see the file COPYING.  If not, write to
  19.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  *
  21.  * As a special exception, the Free Software Foundation gives permission
  22.  * for additional uses of the text contained in its release of GUILE.
  23.  *
  24.  * The exception is that, if you link the GUILE library with other files
  25.  * to produce an executable, this does not by itself cause the
  26.  * resulting executable to be covered by the GNU General Public License.
  27.  * Your use of that executable is in no way restricted on account of
  28.  * linking the GUILE library code into it.
  29.  *
  30.  * This exception does not however invalidate any other reasons why
  31.  * the executable file might be covered by the GNU General Public License.
  32.  *
  33.  * This exception applies only to the code released by the
  34.  * Free Software Foundation under the name GUILE.  If you copy
  35.  * code from other Free Software Foundation releases into a copy of
  36.  * GUILE, as the General Public License permits, the exception does
  37.  * not apply to the code that you add in this way.  To avoid misleading
  38.  * anyone as to the status of such modified files, you must delete
  39.  * this exception notice from them.
  40.  *
  41.  * If you write modifications of your own for GUILE, it is your choice
  42.  * whether to permit this exception to apply to your modifications.
  43.  * If you do not wish that, delete this exception notice.  
  44.  */
  45.  
  46.  
  47. #include "__scm.h"
  48.  
  49.  
  50.  
  51. typedef struct scm_cell
  52. {
  53.   SCM car;
  54.   SCM cdr;
  55. } scm_cell;
  56.  
  57. /* PTR_LT defines how to compare two CELLPTRs (which may not be in the
  58.  * same scm_array).  CELLPTR is a pointer to a cons cell which may be
  59.  * compared or differenced.  SCMPTR is used for stack bounds.
  60.  */
  61.  
  62. #if !defined(__TURBOC__) || defined(__TOS__)
  63.  
  64. typedef scm_cell *SCM_CELLPTR;
  65. typedef SCM  *SCMPTR;
  66.  
  67. # ifdef nosve
  68. #  define SCM_PTR_MASK 0xffffffffffff
  69. #  define SCM_PTR_LT(x, y) (((int)(x)&SCM_PTR_MASK) < ((int)(y)&SCM_PTR_MASK))
  70. # else
  71. #  define SCM_PTR_LT(x, y) ((x) < (y))
  72. # endif /* def nosve */
  73.  
  74. #else /* defined(__TURBOC__) && !defined(__TOS__) */
  75.  
  76. # ifdef PROT386
  77. typedef scm_cell *SCM_CELLPTR;
  78. typedef SCM *SCMPTR;
  79. #  define SCM_PTR_LT(x, y) (((long)(x)) < ((long)(y)))
  80. # else
  81. typedef scm_cell huge *SCM_CELLPTR;
  82. typedef SCM  huge *SCMPTR;
  83. #  define SCM_PTR_LT(x, y) ((x) < (y))
  84. # endif /* def PROT386 */
  85.  
  86. #endif /*  defined(__TURBOC__) && !defined(__TOS__) */
  87.  
  88.  
  89.  
  90. /* Cons Pairs
  91.  */
  92.  
  93. #define SCM_NCONSP(x) (1 & (int)SCM_CAR(x))
  94. #define SCM_CONSP(x) (!SCM_NCONSP(x))
  95. #define SCM_ECONSP(x) (SCM_CONSP(x) || (1==SCM_TYP3(x)))
  96. #define SCM_NECONSP(x) (SCM_NCONSP(x) && (1 != SCM_TYP3(x)))
  97.  
  98. #define SCM_CAR(x) (((scm_cell *)(SCM2PTR(x)))->car)
  99. #define SCM_CDR(x) (((scm_cell *)(SCM2PTR(x)))->cdr)
  100. #define SCM_GCCDR(x) (~1L & SCM_CDR(x))
  101. #define SCM_SETCDR(x, v) SCM_CDR(x) = (SCM)(v)
  102.  
  103. #define SCM_NEWCELL(_into) \
  104.     { \
  105.       if (SCM_IMP(scm_freelist)) \
  106.          _into = scm_gc_for_newcell();\
  107.       else \
  108.         { \
  109.            _into = scm_freelist; \
  110.            scm_freelist = SCM_CDR(scm_freelist);\
  111.            ++scm_cells_allocated; \
  112.         } \
  113.     }
  114.  
  115.  
  116. #ifdef __STDC__
  117. extern SCM scm_cons (SCM x, SCM y);
  118. extern SCM scm_cons2 (SCM w, SCM x, SCM y);
  119. extern SCM scm_listify (SCM elt, ...);
  120. extern SCM scm_acons (SCM w, SCM x, SCM y);
  121. extern SCM scm_pair_p(SCM x);
  122. extern SCM scm_set_car_x(SCM pair, SCM value);
  123. extern SCM scm_set_cdr_x(SCM pair, SCM value);
  124. extern SCM scm_null_p(SCM x);
  125. extern long scm_ilength(SCM sx);
  126. extern SCM scm_list_p(SCM x);
  127. extern SCM scm_list(SCM objs);
  128. extern SCM scm_list_length(SCM x);
  129. extern int scm_obj_length (SCM obj);
  130. extern SCM scm_length(SCM x);
  131. extern SCM scm_append(SCM args);
  132. extern SCM scm_reverse(SCM lst);
  133. extern SCM scm_list_ref(SCM lst, SCM k);
  134. extern SCM scm_memq(SCM x, SCM lst);
  135. extern SCM scm_member(SCM x, SCM lst);
  136. extern SCM scm_assq(SCM x, SCM alist);
  137. extern SCM scm_assoc(SCM x, SCM alist);
  138. extern SCM scm_delq_x (SCM item, SCM lst);
  139. extern SCM scm_last_pair(SCM sx);
  140. extern SCM scm_append_x(SCM args);
  141. extern SCM scm_memv (SCM x, SCM lst);
  142. extern SCM scm_assv(SCM x, SCM alist);
  143. extern SCM scm_list_tail(SCM lst, SCM k);
  144. extern void scm_init_pairs (void);
  145.  
  146. #else /* STDC */
  147. extern SCM scm_cons ();
  148. extern SCM scm_cons2 ();
  149. extern SCM scm_listify ();
  150. extern SCM scm_acons ();
  151. extern SCM scm_pair_p();
  152. extern SCM scm_set_car_x();
  153. extern SCM scm_set_cdr_x();
  154. extern SCM scm_null_p();
  155. extern long scm_ilength();
  156. extern SCM scm_list_p();
  157. extern SCM scm_list();
  158. extern SCM scm_list_length();
  159. extern int scm_obj_length ();
  160. extern SCM scm_length();
  161. extern SCM scm_append();
  162. extern SCM scm_reverse();
  163. extern SCM scm_list_ref();
  164. extern SCM scm_memq();
  165. extern SCM scm_member();
  166. extern SCM scm_assq();
  167. extern SCM scm_assoc();
  168. extern SCM scm_delq_x ();
  169. extern SCM scm_last_pair();
  170. extern SCM scm_append_x();
  171. extern SCM scm_memv ();
  172. extern SCM scm_assv();
  173. extern SCM scm_list_tail();
  174. extern void scm_init_pairs ();
  175.  
  176. #endif /* STDC */
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189. #endif  /* PAIRSH */
  190.